class ListNode:
    def __init__(self, x=None):
        self.val = x
        self.next = None
    def __del__(self):
        self.val = None
        self.next = None


class Solution:
    def DeleteNode(self, pListHead, pToBeDeleted):
        if not pListHead or not pToBeDeleted:
            return None
        if pToBeDeleted.next:
            pNext = pToBeDeleted.next
            pToBeDeleted.val = pNext.val
            pToBeDeleted.next = pNext.next
            pNext.__del__()
        elif pToBeDeleted == pListHead:
            pToBeDeleted.__del__()
            pListHead.__del__()
        else:
            p = pListHead
            while p.next!=pToBeDeleted:
                p=p.next

            p.next=None
            pToBeDeleted.__del__()
        return pListHead


node1 = ListNode(10)
node2 = ListNode(11)
node3 = ListNode(13)
node4 = ListNode(15)
node1.next = node2
node2.next = node3
node3.next = node4

S = Solution()
m=S.DeleteNode(node1, node3)
i=node1
while i!=None:
    print(i.val)
    i=i.next